
//
//  WSJHud.m
//  HandheldELearn
//
//  Created by wsj2015 on 2017/1/18.
//  Copyright © 2017年 陈武琦. All rights reserved.
//

#import "WSJHud.h"


@interface WSJHud ()<MBProgressHUDDelegate>

@end

@implementation WSJHud

#pragma mark - Life

+ (instancetype)sharedHud
{
    static WSJHud *sharedhud = nil;
    //block
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedhud = [[WSJHud alloc] init];
    });
    return sharedhud;
}



- (MBProgressHUD *)showSimple:(UIView *)view
{
    
    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
    hud.removeFromSuperViewOnHide = YES;
    hud.mode = MBProgressHUDModeCustomView;
    hud.margin = 0;
    hud.delegate = self;
   
    
    UIImageView *imageView = [UIImageView new];
    imageView.frame = CGRectMake(0, 0, 0, 0);
    NSMutableArray *arr = [NSMutableArray array];
    for (int i = 1; i<9; i ++) {
        @autoreleasepool {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"animated%d",i]];
            [arr addObject:image];
        }
        
    }
   
   
    imageView.animationImages = arr;
    [imageView sizeToFit];
    
    
    hud.customView =imageView;
    
    [view addSubview:hud];
    [imageView startAnimating];
    [hud show:YES];
    
    return hud;
}

- (void)hide{
   
    
    
}
- (void)hudWasHidden:(MBProgressHUD *)hud{
   
    
}


@end
